home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
356
/
applic
/
2columns.doc
next >
Wrap
Text File
|
1989-02-05
|
23KB
|
481 lines
TWO COLUMN PRINTER (2COLUMNS.PRG) by Jonathan Corey
Version 2 (1/89)
INTRODUCTION
This program prints text (ASCII) files in two "magazine
style" columns and has an option for easy two sided printing
on continuous form paper. Files printed this way use much
less paper and are easier to refer to than those printed
normally. It works very well for printing program source
code listings, program documentation, bulletin board captures
and "online" magazines. 1stWord format files (not Plus) can
be printed although the program will first convert them to
ASCII format and so most of their internal formatting will be
lost. It works in all resolutions.
Printer codes are read from a data file (usually
2COLUMNS.DAT). Instructions for modifying printer codes to
suit your printer are given in a later section of this file.
Data files for several different printers have been provided.
TWO COLUMN PRINTER was developed on a 1040 ST. The
primary printer used during development was an Epson FX-85
but recently much work has been done using a HP Deskjet (no
font cards). It was written in GFA BASIC (Ver 2.02) and
compiled with the GFA BASIC Compiler (Ver 2.02).
Send me (Jonathan Corey) any comments, questions, or
suggestions by directing EMAIL on GEnie to address JWC-OEO.
ENHANCEMENTS
There have been two major enhancements to the program in
this version (Ver 2).
1st...Output can now be directed to a disk file instead of
only to the printer. The processing of several files in one
session goes much more quickly this way. The output file can
be printed with the desktop "Print" option or via a print
spooler. Several files can be combined in one output file.
2nd...An option has been added which reformats paragraphs
that have lines too long to fit into a column. This option
works very well with loosely formatted documents like the one
you are now reading, but should not be used with files such
as program source code that should never have the text of one
line combined with that of another.
Other improvements include: Columns can now be more than
74 lines long; The various print options are now chosen with
a dialog box rather than by the old maze of alert boxes (a
RSC file now accompanies the program); Columns are shifted
towards the outside in order to maximize space for binding
sheets along their inside edge (recommended); Previously
chosen column dimensions are retained as defaults; Some
obscure bugs have been squashed; And the line splitting
routine has been improved.
PRINTER DATA COMPATIBILITY
Printer data files from Version 1 will also work with
version 2. However, to take full advantage of new features
some minor modifications should be made to them. See the
items marked with an asterisk (*) in the Printer Codes
section below.
FITTING A FILE INTO COLUMNS
The basic strategy this program uses to fit files into
columns is simple. It prints as much of a file line on one
column line as possible; then if there's any of it left, it
prints the rest on the next. This leftover portion will
either be combined with the next file line or will be left to
become a column line all by itself. Whether it is combined
or left alone depends on the type of file being printed. The
type of file being printed also determines exactly where and
how any line splitting is done.
TWO COLUMN PRINTER handles program source code listings
differently than other files although it's not very clever
about determining what's source code and what's not. It will
assume that if a file has an extension of TXT or DOC it's
not, otherwise it just asks "Is this source code?". If it
is, choose YES. Even if it's not, you may occasionally want
to lie and say it is because you would like it to be treated
as if it were.
With program source code, the leftover portion of a split
line never gets combined with another file line. Also, all
split lines and continuations of split lines are clearly
marked. For other types of files, line splitting will not
always be clearly marked but it will occur in a much smoother
and more uncluttered manner; also, the Paragraph Reformat
option is available.
When the Paragraph Reformat option has been chosen, any
leftover portion of one file line is combined with the next
file line. This often makes the new line too long for a
column as well, and a chain reaction of sorts is started that
may not stop until the end of the current paragraph. It will
ALWAYS stop there. The paragraph therefore essentially ends
up being reformatted with narrower margins, hence the name of
this option.
For the masochistically curious, the different types of
line splitting are explained in more detail in a later
section.
It's best to minimize the amount of line splitting that
occurs so columns should usually be set as wide as possible.
Does this mean that columns should always be set at their
maximum width? That depends on how you want to bind the
pages together. With maximum width columns, margins become
very small which leaves very little room to bind them along
their inner edge. Since inner edge binding is usually the
best method, the default settings of column width are set a
few characters short of maximum with each type size.
Before beginning to print, the program will indicate how
many, if any, of the file lines were too long to fit the
columns or how many paragraphs had to be reformatted. At
that point you will be given the option of either printing
the file, reformatting it with wider columns, or exiting the
program.
COLUMN LENGTH and LINE SPACING
If columns are set too long to fit on a sheet of paper the
whole output becomes essentially useless. To help avoid
this, Version 1 of TWO COLUMN PRINTER would not allow columns
to be more than 74 lines long. The default maximum column
length with version 2 is a bit smaller at 72 lines but it can
be changed to any value up to 99. To change from the
default, the desired value is added to the printer data file.
A different maximum column length can be set for each type
size.
Maximum column lengths are determined by how close a
printer can print to the top and bottom of a page, and the
line spacing of the print. With this program, printing is
usually done with a line spacing close to 7 lines per inch
(the codes for this spacing come from the printer data file).
Columns can be around 72 lines long on 11 inch continuous
form paper with this spacing. When columns are set to be 60
lines long or less the program usually shifts to a spacing of
6 lines per inch (the "normal" spacing for most printers).
If you wish to use some other line spacing you will need
to add the necessary printer codes for it to the other codes
used to set a particular type size/font. When using type
sizes that include a line spacing in their definition, only
that line spacing can be used. The most useful "other" line
spacing is probably 8 lines per inch. While a line spacing
of 8 lines per inch is awfully cramped with fonts of normal
height, it works fine when fonts of about 7 points or shorter
are used. (Point size is a measure of the how tall a letter
is, 7 point type is pretty short.) When you use 8 lines per
inch line spacing, printed columns can be around 84 lines
long with most printers. Most of the printer data files
supplied with this program include at least one "8 line/inch"
type size.
Exactly how many lines long can columns be with your
printer? If it's not one for which I have included a data
file, then I don't know. The default setting is safe to use
with most printers but if you want a more specific value you
will have to figure it out for yourself. A file has been
included with TWO COLUMN PRINTER to help you with this. It's
called LPC_TEST (LPC = Lines Per Column). It's just 96 short
lines consisting mainly of line numbers. Run it through TWO
COLUMN PRINTER, choosing unequal length columns, and see how
many lines your printer can fit onto a page. You will have
to change the "Maximum Lines per Column" entry in your
printer data file to try larger values. Do the test with
both continuous and single sheets. CAUTION: If your printer
won't let you turn its end-of-paper sensor off (like the HP
Deskjet and Epson LQ-1050) choose a value ONE LESS than that
which will actually print on a single sheet.
With most printers you will probably be able to get more
lines on a sheet with continuous form paper than cut sheets.
Choose whichever value you want but remember, the final sheet
of continuous form paper will usually behave the same as cut
sheet paper. It is for this reason that default values of
column length have been set to be a few lines shorter than
the maximum. The non-default values that are included the
printer data files supplied with this program are all for 11
inch continuous form paper (except the Deskjet of course).
You may not be able to get that many lines on single sheets
or the last sheet of continuous form paper.
TWO SIDED PRINTING
Printing on both sides of the paper has attractive
advantages. It is much easier to refer to what you have
printed, and paper usage is cut almost in half saving both
money and storage space. Even though TWO COLUMN PRINTER can
simplify two sided printing on continuous form paper quite a
bit, more effort is required than with single sided printing.
If it is hard to load paper into your printer it may not be
worth it to you. It is worth trying however.
When the option for printing on both sides of continuous
form paper has been chosen, the program will first print all
the odd numbered pages and then, after a pause to allow you
to turn the paper over, it will print the even numbered ones.
The page number, name of the file, and (optionally) the date
are printed on the top of each page to help keep things
straight. When printing to disk, the even and odd pages of
two sided files go into separate output files. Several files
can be put into one output file further reducing the paper
handling required to print them. Never combine files
formatted for one and two sided printing into the same output
file.
LINE SPLITTING
When a line is too long for a column a portion of it gets
moved to a new line. After that two things can happen. The
excess will either be left to become a new line all by
itself, or it will be combined with the next line down. It
will only be combined with the next line when the paragraph
reformat option has been turned on AND the next line is not
blank or does not begin with one or more spaces.
The point at which an excessively long line is split is
determined as follows...
With most files, the last eight characters before the edge
of a column are searched for a blank space. The split will
occur at the first one found. If there are no spaces in the
last eight characters the last word will be hyphenated
(expediently) and the line split after the hyphenation. One
exception to this occurs when the character just before the
hyphenation is a number (actually if it has an ASCII value
less than 65). In this case a vertical bar "|" is used
instead of a hyphen since the hyphen could be confused with a
minus sign when next to a number. A vertical bar is also
added at the start of the next line to indicate than a number
has been split.
A different method is used with source code listings
because source code may not have all that many blank spaces
(GFA BASIC for example) and any dashes added as part of
hyphenation could easily be confused with minus signs. When
you have declared a file as being program source code any
necessary splitting will occur three characters short of the
point at which a line becomes too long for a column (without
regard for the context of the line). To indicate a split has
occurred the characters ``> are added at the split point. To
indicated a line is the continuation of the previous one, the
characters >`` are added in front of it.
FORMATTED TEXT FILES
Some text files have been formatted to have a nice formal
appearance when printed straight from the desktop. They
often have an indented left margin so that printing begins
several spaces in from the left side of the paper. This
looks better with normal printing but only wastes paper here.
TWO COLUMN PRINTER has an option which will enable you to
easily check for and get rid of any left margin indent.
Unfortunately the paragraph reformat option does not work
with files that have indented left margins. However, once
the indent has been eliminated the file is not likely to have
any lines too long to fit the columns.
Formatted text files often contain page numbers which are
sometimes preceded by a number of blank lines. You might
want to eliminate these blank lines with a word processor or
text editor before printing with TWO COLUMN PRINTER as they
will just waste paper. Keep the page numbers though, they
won't correspond to the actual page numbers when printed with
TWO COLUMN PRINTER but can serve as a useful reference,
especially if the file contains an index.
MISCELLANEOUS
You can change the extension shown in the file selector
box to the wildcard "*" by clicking on OK without first
selecting a file. This works best if it's done before
setting a different drive or folder.
The program does some error checking on the file you ask
it to print and rejects those it identifies as inappropriate
(not ASCII or 1STWORD format). If for some reason it rejects
a file you are sure should work (it is readable when
displayed by the desktop SHOW option), change the extension
of the file name to .TXT or .LST and try again. No error
checking for file type is done on files with these
extensions.
Any TAB's found in a file are changed to three blank
spaces before printing.
_____________________________________________________________
*** Printer Codes ***
GENERAL
Printer data files for several printers have been
provided. If your printer is Epson compatible (or you have a
Deskjet) then one them will likely work fine. If not, you
will have to do some editing. For this you will need your
printer manual. Edit a backup copy of one of these files
using a text editor or word processor and save it as a simple
text (ASCII) file (not in any special word processor mode)
giving it a new name.
The data files provided have descriptive names such as
EPSON_FX.DAT (all use the extension DAT). They are designed
for the standard mode of these printers so if you have one of
them but have its DIP switches set for IBM mode you may need
to modify the codes accordingly. The Epson-FX codes which
were developed on an FX-85 have also been tested on an Epson
LX-800 and FX-80 and work quit well. The LQ codes were
developed on an Epson LQ-1050. Some earlier Epson LQ
printers (such as the LQ-1500) cannot do NLQ with type sizes
less than 12 CPI (Characters Per Inch). Double strike should
be used instead of NLQ for "enhanced printing" with these
printers (necessary codes for this are shown in the remarks
section of this data file). The DESKJET codes were derived
on a Hewlett-Packard Deskjet with no font cards installed.
The Panasonic KX-P1091i codes have not been tested on other
models of the same brand. The STAR SG10 codes are based only
on the printer manual and have not been tested.
Unless you have two (or more) printers that use different
codes you may want to change the name of your printers data
file to 2COLUMNS.DAT. You will no longer have to select a
data file each time the program is run this way since the
program automatically loads 2COLUMNS.DAT if it finds it on
the same disk (and in the same folder) as the program.
EDITING A PRINTER CODE FILE
Follow the data format exactly as shown. Use 3 digit
decimal ASCII values for printer codes. Separate them with a
single space and put a comma after the last one. Remarks
(optional) may follow the comma (mandatory). THERE CAN BE NO
OTHER COMMAS ANYWHERE ELSE IN THE DATA SECTION, including in
the remarks themselves. The "-----CODES AND DEFAULTS----"
line needs to be left intact.
Example: A printer function which requires the code "Escape
A" would be encoded as:
027 065, REMARKS
(the ASCII value of Escape is 027, that of A is 065.) Again,
no commas are allowed in the remarks themselves.
Printer functions requiring multiple codes are allowed. In
the Epson FX version supplied with the program the codes for
type size #2 contain both the codes for compressed type
( 027 015 ) and for wider margins with this type size
( 027 081 137 ). The only limitation is that all codes and
the remarks that follow must fit on a single line (which can
be up to 255 characters long).
* Line-by-line editing instructions are given below. Those
entries preceded by an asterisk (*) have changed since
version 1.
Paper-Out Sensor
The first two entries in the "CODES AND DEFAULTS" section
are: 1) Disable (turn off) the paper-out sensor, and 2)
Enable (turn on) the paper-out sensor. If your printer does
not allow its paper-out sensor to be turned off, just enter a
single blank space followed by a comma (see DESKJET.DAT).
Line Spacing
Next enter the codes for 7 line per inch line spacing.
You will probably find that you can only come up with a value
equivalent to slightly more or slightly less than this.
(7 lines per inch is a spacing of 0.143 inch) In this case
choose the next smallest value available. For example the
Epson-FX definition uses 10/72 (0.139) inch spacing.
* Printer Initialization
To work properly with this program your printer has to
have certain settings in effect before printing begins.
Initial conditions needed are: A pitch of 10 characters per
inch (CPI), Draft mode, 6 lines per inch line spacing, and
top-of-form reset. An "initialize" sequence is sent to
ensure that these conditions are met.
The codes which need to be included in this sequence vary
somewhat from printer to printer and also will depend on how
you normally have your printer's DIP switches and control
panel buttons set.
To do the top-of-form setting, add the codes which are
described in most printer manuals as Initialize Printer or
Reset Printer. To be safe you should also include the codes
to set 10 CPI and Draft Mode printing.
If you have a type size that uses the Super/Sub script
font of your printer you will also need to add the codes to
cancel this font to the initialize printer sequence. The
Epson FX definition does this. (Alternately, but not as
simply, you could add "cancel super/sub script font" codes to
each non-super/sub script font definition.)
Unless you have your printers DIP switch set at 8 lines
per inch you will not need to enter the codes for 6 lines per
inch line spacing.
The Initialize printer sequence for the HP Deskjet
contains some other codes as well. See the "Note" at the
bottom of its data file.
Some printers (such as the Panasonic KX-P1091i) have
control panel settings which cannot be changed by software.
TWO COLUMN PRINTER cannot function properly when these are
set to NLQ mode. You must switch to draft mode (the
Panasonic KX-P1091i calls this "Std Pgm") before printing.
Skip-Over-Perforations
Enter the codes to turn OFF your printers Skip-Over-
Perforations function. TWO COLUMN PRINTER handles page
breaks itself and if you leave "skip over perforations" on it
will interfere with the proper operation of the program
(a lot).
* Fancy Print for the Heading
TWO COLUMN PRINTER puts a heading consisting of the name
of the file being printed (and optionally the current date)
on the first printed page. For this to print properly you
will need to enter the codes for Double Width (expanded)
printing. If you do not use Double Width printing (or 5
pitch in the case of the Deskjet) the heading will not be
centered properly.
Enhanced Print
The entry for Enhanced Print affects the main body of the
text. Choices for this are either Near Letter Quality (NLQ)
or Double Strike printing. Choose NLQ only if it works with
all the type sizes included in your data file, otherwise
choose Double Strike.
Default Extension
Only files with the extension you enter here will be shown
in the file selector box the first time you are prompted for
a file name to print. This entry must not exceed three
characters and must be surrounded by quotes. If you prefer
that all files be shown then enter "*" or just "" here (don't
forget the comma).
Number of Type Sizes
Five is the maximum. MAKE SURE THIS NUMBER IS NOT LARGER
THAN THE NUMBER OF TYPE SIZES IN YOUR DATA FILE. It can be
smaller though since the program will only read in this
number of type sizes and will ignore the rest. If you choose
to use less then the maximum number of type sizes (5) you may
(although it is not necessary to) delete the entries for any
unneeded codes. Do not delete any other lines in the codes
section.
* Entries for Each Type Size
The name of each type size should not exceed 25
characters. Other than the fact that no commas are allowed
you can put any descriptive information you like here. The
name must be surrounded by quotation marks (these do not
count as characters in the name). Like all other entries the
name MUST be followed by a comma and optional descriptive
remarks may follow the comma.
The codes used to select a type size can also contain the
codes for a particular line spacing. If included, only that
line spacing will available with this type size.
The entry for the number of characters that will fit on a
full line is mandatory. Take this value from your printer
manual if possible (sometimes given as the maximum value
allowed for the right margin). If you cannot find it there
then try 160 for 20 CPI, 136 for 17 CPI, 120 for 15 CPI, 96
for 12 CPI, and 80 for 10 CPI. Arithmetically inclined
individuals will be able to discern a pattern here. These
values are for narrow carriage printers. If you are using a
wide carriage model you can probably add a character or two
to them.
On the next line you may enter a number equal to the
maximum column length possible with this type size (99 is
maximum). This optional entry is useful if you have a
particular line spacing included in the codes for this type
size, if your printer can print more or cannot print as many
lines per column as the default value, or if you will be
using something other than 11 inch paper. The default value
is 72 lines per column and if no entry is made here the
default value will be the maximum column length allowed.
Like all entries, it must be followed by a comma and remarks
may follow the comma.
Proportionally spaced fonts cannot be used.